package com.icinfo.cloud.provider.punish.service.impl;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.icinfo.cloud.provider.common.page.PageResponse;
import com.icinfo.cloud.provider.common.utils.HeaderUtil;
import com.icinfo.cloud.provider.punish.config.dto.PhraseQueryPageDto;
import com.icinfo.cloud.provider.punish.config.vo.PhraseVo;
import com.icinfo.cloud.provider.punish.service.IConfigCasePhrasesService;
import com.icinfo.framework.common.web.Result;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 短语 相关
 * @author Administrator
 */
@Service
public class ConfigCasePhrasesServiceImpl implements IConfigCasePhrasesService {

    @Value("${tzService.url}")
    private String url;

    @Override
    public Result<PageResponse<PhraseVo>> getList(PhraseQueryPageDto phraseQueryPageDto) {
        Map<String, String> headers = HeaderUtil.headerInfo();
        String param = JSON.toJSONString(phraseQueryPageDto);
        String response = HttpUtil.createPost(url.concat("phrase/getPhraseList")).addHeaders(headers).body(param).execute().body();
        Result<PageResponse<PhraseVo>> result = JSON.parseObject(response, Result.class);
        return result;
    }



}
